package com.example.uCenter.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;


@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result implements Serializable {
    private Object data;     // 数据
    private Integer code;    // 状态码
    private String msg;      // 状态码说明
    /**
     * 成功
     *
     * @param data 返回的数据
     * @return
     */
    public static Result ok(Object data) {
        return new Result(data, 200, "OK");
    }

    /**
     * 成功
     */
    public static Result ok() {
        return ok(null);
    }

    /**
     * 失败
     *
     * @return
     */
    public static Result fail() {
        return new Result(null, 400, "Fail");
    }
}
